package xyz.xtt.asset.api.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author huqibo
 * 
 *         协议标准
 */
public enum ReferProtocolEnum {
	/**
	 * 721
	 */
	ERC_7211(721L, "721"),
	/**
	 * 1155
	 */
	ERC_1155(1155L, "1155");

	private Long code;

	/**
	 * 描述
	 */
	private String description;

	ReferProtocolEnum(Long code, String description) {
		this.code = code;
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public Long getCode() {
		return code;
	}

	public static ReferProtocolEnum convert(String tokenType) {
		return Arrays.asList(ReferProtocolEnum.values()).stream().filter(x -> Objects.equals(x.getDescription(), tokenType)).findFirst().orElseGet(null);
	}

	public static ReferProtocolEnum convert(Long tokenType) {
		return Arrays.asList(ReferProtocolEnum.values()).stream().filter(x -> Objects.equals(x.getCode(), tokenType)).findFirst().orElseGet(null);
	}

	public static ReferProtocolEnum convertWithCode(Long code) {
		return Arrays.asList(ReferProtocolEnum.values()).stream().filter(x -> Objects.equals(x.getCode(), code)).findFirst().orElseGet(null);
	}
}
